/*
 * All right reserved@Raygo 2022~2030
 */

package com.raygo.runner.core.entity;

import java.util.List;

import com.raygo.runner.core.annotation.ComponentDefine;
import com.raygo.runner.core.annotation.MethodDefine;
import com.raygo.runner.core.result.BoolResult;

/**
 * 基础组件
 *
 * @author Raygo
 * @since 2022年5月21日
 */
@ComponentDefine(desc = { "基础组件" }, id = "20220521223617", name = "各个组件的基类")
public class BaseComponent implements Component {
    protected final String VERSION = "1.0.0";
    /**
     * 上下文信息
     */
    protected Context context;

    /**
     * 默认方法
     *
     * @param params 参数
     * @return 结果
     */
    @MethodDefine(desc = { "组件执行时的默认方法" }, id = "default", name = "默认方法")
    protected BoolResult defaultMethod(List<Object> params) {
        return new BoolResult();
    }

    @Override
    public BoolResult init(Context context) {
        this.context = context;
        return new BoolResult();
    }

    @Override
    public BoolResult run(String method, List<Object> params) {
        return defaultMethod(params);
    }

    @Override
    public BoolResult exit() {
        return new BoolResult();
    }

    @Override
    public String getVersion() {
        return VERSION;
    }
}
